<?php
// ddd_redirect
function ddd_redirect($url) {
  header ("Location: " . $url); 
}

// set_flash
function set_flash($message) {  
  $_SESSION["flash"] = $message;
}

// get_flash
function get_flash($destroy) {
  if (array_key_exists("flash", $_SESSION)) {
    $msg = $_SESSION["flash"];
    if ($destroy) {
      $_SESSION["flash"] = null;
    }

    return $msg;
  } else {
    return false;
  }
}

// set_cookie
function set_cookie($name, $value) {
  setcookie($name, $value, time()+3600*5);
}

// Recursive remove a dir
function recursive_rmdir($dir) { 
if (is_dir($dir)) { 
  $objects = scandir($dir); 
  foreach ($objects as $object) { 
    if ($object != "." && $object != "..") { 
      if (filetype($dir."/".$object) == "dir") recursive_rmdir($dir."/".$object); else unlink($dir."/".$object); 
    } 
  } 
  reset($objects); 
  rmdir($dir); 
  } 
} 

?>


